#ifndef FPLAYER_HANDLERTHREAD_H
#define FPLAYER_HANDLERTHREAD_H

#include "Thread.h"
#include "queue/Handler.h"

/**
 * author: x-fan
 * date: 2024/1/9
 * desc: Handler线程
 */
class HandlerThread : public Thread, protected IHandlerCallback {
private:
  Handler *_pHandler;

public:
  HandlerThread();

  explicit HandlerThread(Handler *pHandler);

  virtual ~HandlerThread() noexcept;

  void running(void *pPtr) override;

  void stopThread() override;

  /**
   * 发送消息
   * @param what 消息ID
   * @return true: 发送消息成功
   */
  bool sendMessage(int32_t what);

  /**
   * 发送消息
   * @param pMsg 消息体
   * @return true: 发送消息成功
   */
  bool sendMessage(Message *pMsg);

};


#endif //FPLAYER_HANDLERTHREAD_H
